import logging

from flask import Flask
from blueprints.indexBp import indexBp as index
from blueprints.offsetBp import offsetBp as offset
from blueprints.healthcheck import healthcheckBp as healthcheck
from utils import configUtil, logUtils
from openai import OpenAI

app = Flask(__name__)

app.register_blueprint(index)
app.register_blueprint(offset)
app.register_blueprint(healthcheck)

if __name__ == '__main__':
    # client = OpenAI()
    #
    # completion = client.chat.completions.create(
    #     model="gpt-3.5-turbo",
    #     messages=[
    #         {"role": "user", "content": "hello"}
    #     ]
    # )
    #
    # print(completion.choices[0].message)

    cf = configUtil.ConfigUtil("conf/init.conf")
    app.logger.addHandler(logUtils.getLogHanderTime(cf.log_path))
    app.logger.setLevel(logging.DEBUG)
    app.logger.info('app startup')
    app.run(host='0.0.0.0', port=cf.server_port, debug=True)
